﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsXIANGMU
{
    public partial class FormSC : Form
    {
        public FormSC()
        {
            InitializeComponent();
        }

        private void FormSC_Load(object sender, EventArgs e)
        {
            string sql = "select * from BirthdayCT";
            DataTable table = DBHelper.hehe(sql);
            dataGridView1.AutoGenerateColumns = false;
            dataGridView1.DataSource = table;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count > 1)
            {
                MessageBox.Show("不能选中多行");
            }
            else
            {
                if (MessageBox.Show("确定要删除么", "警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
                {
                    string sql = string.Format("delete from BirthdayCT where BID={0}", dataGridView1.SelectedCells[0].Value.ToString());
                    bool rs = DBHelper.GetExecuteNonQuery(sql);
                    if (rs == true)
                    {
                        MessageBox.Show("删除成功");
                    }
                    else
                    {
                        MessageBox.Show("删除失败");
                    }
                }

            }
        }
    }
}
